var m4wd_backbone_router = Backbone.Router.extend({
    routes : {
        //main
        '' : 'dashboard',
        'dashboard' : 'dashboard',
        //cars
        //'cars' : 'cars',
        //'cars/:action' : 'carsAction',
        'cars(/)(:action)(/)(:ident)' : 'cars',
        //races
        //'races' : 'races',
        //'races/:action' : 'races',
        'races(/)(:action)(/)(:ident)' : 'races',
        //race entries
        //view all entries in a race
        'race-entries/:action/:race/entries/:action' : 'raceEntriesAction',
        //action on specific entry in race
        'races/:race/entries/:action/:entry' : 'raceEntriesAction',
        //static main menu
        //'main-menu' : 'mainMenu'
    },
    defaultRoute : null,
    initialize : function() {
        this.defaultRoute = 'dashboard';
    },
    //dashboard
    dashboard : function(params) {
        console.log('dashboard');
        /*
         var app = new m4wd_con_dash({
         container : this.getContainer(),
         options : {
         changeHash : false
         }
         });
         app.go();
         */
    },
    //cars
    cars : function(action, ident) {
        console.log('cars' + '-' + action + '-' + ident);
        var view = null;
        var pageId = __app.makePageId('cars', action, ident);
        switch(action){
            case 'add':
            case 'edit':
                view = new vie_car_edit({
                    container: __app.getSection(pageId),
                    car: ident
                });
                view.render();
                __app.changePage(pageId);
                
                break;
            case 'remove':
                if(typeof ident != 'undefined' && ident != null){
                    
                }
                break;
            default: 
            case 'view':
                if(__app.getRenderedView(pageId) == null){
                    var view = new vie_cars({
                        container: __app.getSection(pageId),
                        car: ident
                    });
                    view.render();
                }
                __app.changePage(pageId);
                break;
        }
        view = null;
        pageId = null;
    },
    //races
    races : function(action, ident) {
        console.log('races' + '-' + action + '-' + ident);
        var view = null;
        var pageId = __app.makePageId('races', action, ident);
        switch(action){
            case 'add':
            case 'edit':
                view = new vie_race_edit({
                    container: __app.getSection(pageId),
                    race: ident
                });
                view.render();
                __app.changePage(pageId);
                break;
            case 'remove':
                if(util_fwk_base.isDefined(ident)){
                    
                }
                break;
                
            case 'edit-entry':
                
                break;
            default: 
            case 'view':
                if(__app.getRenderedView(pageId) == null){
                    var view = new vie_races({
                        container: __app.getSection(pageId),
                        race: ident
                    });
                    view.render();
                }
                __app.changePage(pageId);
                break;
        }
        view = null;
        pageId = null;
    },
    
    //race entries
    raceEntriesAction: function(race, action, ident){
        console.log('raceEntriesAction' + '-' + race +'-' + action  + '-entries-' + ident);
    }
    
    
});

